


//#include <stdio.h>
//
////struct aa 
////{
////	int a;
////} main()
////{
////
////}
//
//int main()
//{
//	/*int a1[] = { 1, 2, 3, 4, 5 };
//	int a2[] = { 1, 2, 3, 4, 5, };
//
//	printf("%d %d", sizeof(a1), sizeof(a2));*/
//
//	for (int i = 1; i < 6; ++i)
//	{
//		printf("%d, ", i);
//	}
//	putchar('\n');
//
//	for (int i = 1; i < 6; ++i)
//	{
//		if (5 == i)
//			printf("%d", i);
//		else
//			printf("%d, ", i);
//	}
//	putchar('\n');
//
//
//	return 0;
//}

#include <iostream>
using namespace std;

class Solution
{
public:
	int countDigitOne1(int n)
	{
		int res = 0;
		int cur = n % 10, high = n / 10, low = 0;

		for (long long power = 1; high || cur; power *= 10)
		{
			if (cur > 1)
				res += int((high + 1) * power);
			else if (cur < 1)
				res += int(high * power);
			else
				res += int(high * power + low + 1);

			low += cur * power;
			cur = high % 10;
			high /= 10;
		}

		return res;
	}

	int countDigitOne2(int n)
	{
		int res = 0;

		for (long long power = 1; power <= n; power *= 10)
		{
			int high = n / (power * 10);
			int cur = n / power % 10;
			int low = n % power;

			if (cur > 1)
				res += int((high + 1) * power);
			else if (cur < 1)
				res += int(high * power);
			else
				res += int(high * power + low + 1);
		}

		return res;
	}
};

int cnt1(int i)
{
	int cnt = 0;

	while (i)
	{
		if (1 == i % 10)
			++cnt;
		i /= 10;
	}

	return cnt;
}

void Test1()
{
	int res = 0;
	const int n = 3012;

	for (int i = 0; i <= n; ++i)
	{
		res += cnt1(i);
	}

	printf("0-%d: ", n);
	cout << res << endl;
	cout << Solution().countDigitOne2(n) << endl;
}

int main()
{
	Test1();


	return 0;
}